package main

import (
	"fabricTest/sdkInit"
	"fmt"
	"os"
)

const (
	cc_name2 = "simplecc"
	cc_version2 = "1.0.0"
)
func twoChannel() {
	// init orgs information
	orgs := []*sdkInit.OrgInfo{
		{
			OrgAdminUser:  "Admin",
			OrgName:       "Org2",
			OrgMspId:      "Org2MSP",
			OrgUser:       "User1",
			OrgPeerNum:    1,
			OrgAnchorFile: os.Getenv("GOPATH") + "/src/fabricTest/fixtures/channel-artifacts/Org2Panchors.tx",
		},
	}

	// init sdk env info
	info := sdkInit.SdkEnvInfo{
		ChannelID:        "org2channel",
		ChannelConfig:    os.Getenv("GOPATH") + "/src/fabricTest/fixtures/channel-artifacts/org2channel.tx",
		Orgs:             orgs,
		OrdererAdminUser: "Admin",
		OrdererOrgName:   "OrdererOrg",
		OrdererEndpoint:  "orderer.example.com",
		ChaincodeID:      cc_name2,
		ChaincodePath:    os.Getenv("GOPATH") + "/src/fabricTest/chaincodetwo/",
		ChaincodeVersion: cc_version2,
	}

	// sdk setup
	sdk, err := sdkInit.Setup("configTwo.yaml", &info)
	if err != nil {
		fmt.Println(">> SDK setup error:", err)
		os.Exit(-1)
	}

	// create channel and join
	if err := sdkInit.CreateAndJoinChannel(&info); err != nil {
		fmt.Println(">> Create channel and join error:", err)
		os.Exit(-1)
	}

	// create chaincode lifecycle
	if err := sdkInit.CreateCCLifecycle(&info, 1, false, sdk); err != nil {
		fmt.Println(">> create chaincode lifecycle error: %v", err)
		os.Exit(-1)
	}

	// invoke chaincode set status
	fmt.Println(">> 通过链码外部服务设置链码状态......")

}